<template>
  <div class="sidebar">
    <el-menu
      class="sidebar-el-menu"
      :default-active="onRoutes"
      :collapse="collapse"
      background-color="#324157"
      text-color="#bfcbd9"
      active-text-color="#20a0ff"
      unique-opened
      router>
      <template v-for="item in items">
        <template v-if="item.subs">
          <el-submenu :index="item.index" :key="item.index">
            <template slot="title">
              <i :class="item.icon"></i>
              <span slot="title">{{ item.title }}</span>
            </template>
            <template v-for="subItem in item.subs">
              <el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
                <template slot="title">{{ subItem.title }}</template>
                <el-menu-item
                  v-for="(threeItem,i) in subItem.subs"
                  :key="i"
                  :index="threeItem.index"
                >{{ threeItem.title }}
                </el-menu-item>
              </el-submenu>
              <el-menu-item v-else :index="subItem.index" :key="subItem.index">{{ subItem.title }}</el-menu-item>
            </template>
          </el-submenu>
        </template>
        <template v-else>
          <el-menu-item :index="item.index" :key="item.index">
            <i :class="item.icon"></i>
            <span slot="title">{{ item.title }}</span>
          </el-menu-item>
        </template>
      </template>
      <el-footer height="180px" v-if="!collapse" class="copyright-footer">
        <el-row :gutter="24">
          <el-col :span="24"><i class="el-icon-info"></i>
            <el-link :href="$decrypt.decrypt($video_url)" target="_blank" :underline="false">
              {{$decrypt.decrypt($video_title)}}
            </el-link>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="24"><i class="el-icon-s-cooperation"></i>
            <el-link :href="$decrypt.decrypt($yyc_url)" target="_blank" :underline="false">
              {{$decrypt.decrypt($copy_right)}}
            </el-link>
          </el-col>
        </el-row>
        <!--<el-row :gutter="24">
          <el-col :span="24"><i class="el-icon-s-home"></i> {{$decrypt.decrypt($gszj)}}</el-col>
        </el-row>-->
        <el-row :gutter="24">
          <el-col :span="24"><i class="el-icon-s-custom"></i> {{$decrypt.decrypt($xskf)}}</el-col>
        </el-row>
        <el-row :gutter="24">

          <img style="width: 100px;" src="../../assets/img/qrcode.png"/>
		           <img style="width: 100px;" src="../../assets/img/qrcodewx.png"/>


        </el-row>

      </el-footer>
    </el-menu>
  </div>
</template>

<script>
  import bus from '../common/bus'

  export default {
    data() {
      return {
        collapse: false,
        items: [
          {
            icon: 'el-icon-lx-home',
            index: 'dashboard',
            title: '系统首页'
          },
          {
            icon: 'el-icon-lx-people',
            index: 'user-manager',
            title: '用户管理',
            subs: [
              {
                index: 'user-list',
                title: '用户列表'
              },
              {
                index: 'invite-list',
                title: '推广记录'
              },
              {
                index: 'change-list',
                title: '账变记录'
              },
              {
                index: 'withdraw-list',
                title: '提现管理'
              },
              {
                index: 'user-log',
                title: '用户登录日志'
              },
              {
                index: 'user-action-log',
                title: '用户操作日志'
              },
              {
                index: 'user-comment',
                title: '评论列表'
              }
            ]
          },
          {
            icon: 'el-icon-lx-apps',
            index: 'video-manager',
            title: '视频管理',
            subs: [
              {
                index: 'video-list',
                title: '视频列表'
              }/*,
                            {
                                index: 'video-upload',
                                title: '上传视频'
                            }*/
            ]
          },
          {
            icon: 'el-icon-lx-apps',
            index: 'vip-manager',
            title: 'VIP商品管理',
            subs: [
              {
                index: 'vip-shop-list',
                title: '商品列表'
              },{
                index: 'vip-payment-list',
                title: '支付方式列表'
              }
            ]
          },
          {
            icon: 'el-icon-lx-apps',
            index: 'order-manager',
            title: '订单管理',
            subs: [
              {
                index: 'order-list',
                title: '订单列表'
              }
            ]
          },
          {
            icon: 'el-icon-lx-apps',
            index: 'text-image-manager',
            title: '图文管理',
            subs: [
              {
                index: 'text-image-list',
                title: '图文列表'
              }/*,
                            {
                                index: 'video-upload',
                                title: '上传视频'
                            }*/
            ]
          },
          {
            icon: 'el-icon-lx-apps',
            index: 'cipher-manager',
            title: '卡密管理',
            subs: [
              {
                index: 'cipher-list',
                title: '卡密列表'
              }
            ]
          },
          {
            icon: 'el-icon-lx-settings',
            index: 'comment-manager',
            title: '站点配置',
            subs: [
              {
                icon: 'el-icon-rank',
                index: 'config-basic',
                title: '基本配置'
              },
              {
                icon: 'el-icon-rank',
                index: 'config-comment',
                title: '评论设置'
              },
              {
                index: 'config-payment',
                title: '支付配置'
              },
              {
                index: 'config-sms',
                title: '短信配置'
              },
              {
                index: 'config-mail',
                title: '邮件配置'
              },
              {
                index: 'config-upload',
                title: '上传配置',
                subs: [
                  {
                    index: 'upload-qiniu',
                    title: '七牛云配置'
                  },
                  {
                    index: 'upload-aliyun',
                    title: '阿里云配置'
                  },
                  {
                    index: 'upload-ftp',
                    title: 'FTP配置'
                  }
                ]
              },
              /*{
                  index: 'config-ext',
                  title: '附件配置'
              },*/
              {
                index: 'config-seo',
                title: 'SEO配置'
              },
              {
                index: 'config-video',
                title: '视频配置'
              },
              {
                index: 'config-login',
                title: '登录设置',
                subs: [
                  {
                    index: 'login-wechat',
                    title: '微信登录设置'
                  },
                  {
                    index: 'login-qq',
                    title: 'QQ登录设置'
                  },
                  {
                    index: 'login-weibo',
                    title: '微博登录设置'
                  }
                ]
              },
              {
                index: 'config-safe',
                title: '内容安全',
                subs: [
                  {
                    index: 'safe-cy',
                    title: '护驾卫士'
                  },
                ]
              }
            ]
          },
          {
            icon: 'el-icon-lx-profile',
            index: 'admin-manager',
            title: '管理员管理',
            subs: [
              {
                index: 'admin-list',
                title: '管理员列表'
              },
              {
                index: 'admin-log',
                title: '管理员日志'
              }
            ]
          },
          {
            icon: 'el-icon-menu',
            index: 'type-manager',
            title: '分类管理',
            subs: [
              {
                index: 'type-list',
                title: '分类列表'
              }
            ]
          },
          {
            icon: 'el-icon-s-goods',
            index: 'advert-manager',
            title: '广告配置',
            subs: [
              {
                index: 'advert-list',
                title: '广告列表'
              }
            ]
          },
          {
            icon: 'el-icon-s-cooperation',
            index: 'update-manager',
            title: 'APP版本管理',
          },
          {
            icon: 'el-icon-s-data',
            index: 'stat-manager',
            title: '信息统计',
          }
        ]
      }
    },
    computed: {
      onRoutes() {
        return this.$route.path.replace('/', '')
      }
    },
    created() {
      // 通过 Event Bus 进行组件间通信，来折叠侧边栏
      bus.$on('collapse', msg => {
        this.collapse = msg
        bus.$emit('collapse-content', msg)
      })
    }
  }
</script>

<style lang="scss">
  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
    .el-col {
      &:hover {
        color: #3ab9d9;
      }
    }
  }

  .copyright-footer {
    position: relative;
    bottom: 0px;
    font-size: 14px;
    margin: 24px 0;
    color: #ffffff;
    .el-row{
      cursor: pointer;
      white-space:nowrap; overflow:hidden;
    }
    .el-link.el-link--default {

      &:hover {
        color: #3ab9d9;
      }
      color: #ffffff;
    }
  }

  .sidebar {
    display: block;
    position: absolute;
    left: 0;
    top: 70px;
    bottom: 0;
    overflow-y: scroll;
	background-color: #324157;
  }

  .sidebar::-webkit-scrollbar {
    width: 0;
  }

  .sidebar-el-menu:not(.el-menu--collapse) {
    width: 250px;
  }

  .sidebar > ul {
    height: 100%;
  }
</style>
